<?php
namespace app\qianyu\model;
use think\Db;
use think\Model;
use think\Cache;

class Index extends Model
{
    protected $table = 'cbdd_area';
    // 查看首页详情
    public function getListData($level)
    {   
        $cache = Cache::get('licensePlate');
        if($cache){
            return $cache;
        }
        if($level){
            $where['level'] = $level;
        }else{
            $where['level'] = ['gt',$level];
        }
        $data = $this->name('area')
            ->where('status',1)
            ->where($where)
            // ->order('sort desc')
            ->select();
            if(!$level){
                $data = getTreeDataPhp($data);
            }
        Cache::set('licensePlate',$data);
        return $data;
    }
    // 查看首页详情
    public function getDetailData($id)
    {
        $data = $this->name('slzd_rrb_list')
            ->where('status',1)
            ->where('id',$id)
            ->order('sort desc')
            ->select();
        return $data;
    }
}